package com.app.newiptv.adaper;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.app.newiptv.R;
import com.app.newiptv.base.MyApplication;
import com.app.newiptv.presenter.SitcomOrderPresenter;


/**
 * Created by Shinelon on 2017/9/15.
 */

public class SitcomOrderAdapter extends RecyclerView.Adapter<SitcomOrderAdapter.MainRecycleViewHolder> {
    private SitcomOrderPresenter presenter;
    private int count;

    public SitcomOrderAdapter(SitcomOrderPresenter presenter) {
        this.presenter = presenter;
    }

    public void setCount(int count) {
        this.count = count;
    }


    @Override
    public MainRecycleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_ordersitcom_view, null);
        MainRecycleViewHolder mainRecycleViewHolder = new MainRecycleViewHolder(view);
        return mainRecycleViewHolder;
    }

    @Override
    public void onBindViewHolder(MainRecycleViewHolder holder, int position) {
        presenter.onBindMainChanelView(holder, position);
        holder.setPosition(position);
    }

    @Override
    public int getItemCount() {
        return count;
    }

    public class MainRecycleViewHolder extends RecyclerView.ViewHolder implements SitcomOrderPresenter.MainViewHolder {

        private int position;
        private TextView mBtn_xj;

        public MainRecycleViewHolder(View itemView) {
            super(itemView);
            mBtn_xj = (TextView) itemView.findViewById(R.id.orderindex_text);

//            itemView.setOnClickListener(new View.OnClickListener() {
//                @Override
//                public void onClick(View v) {
//                    Log.d("tag","------position------"+position);
//                    presenter.loadSitcom(position);
//                }
//            });
        }

        private void setPosition(int position) {
            this.position = position;
        }

        @Override
        public void setNumber(String index) {
            if (mBtn_xj != null) {
                mBtn_xj.setTypeface(MyApplication.face);
                mBtn_xj.setText(index);
            }
        }
    }
}
